man2html: unable to open or read file /usr/lib/ms/ms.acc
#include "<SOS>/include/trc.h"
trc provides functions for trace output within source programs that can be turned on and off (without recompilation) and that can be divided into different trace levels. Having completed the test phase, the additional code can be eliminated by a compile time switch (compile option -DNO_TT).
The standard way to produce trace output is to set the Unix environment variable SOSTRCLEVEL prior to calling a program which uses the trace facility. This variable is interpreted with the call T_INIT (see below). The string to which the tracelevel variable is set consists of a prefix with an arbitrary sequence of items of the following form:
The remainder of the tracelevel string specifies individual ranges of trace switches to be activated:
For example, the Unix csh-command setenv SOSTRCLEVEL id100#214#250-260 turns on indentation mode, makes pointers printed in decimal form, and activates the trace switches 0 to 100, 214, and 250 to 260.
The name of the trace output file is given as string parameter to the call of T_INIT. If the named file does not exist, it is created, otherwise truncated. If the tracelevel option s is given, trace output is directed to the screen, instead. The output file will then only contain the starting and ending time of the process. The close-on-exec flag (see fcntl(2)) is set for the trace output file, i.e. a program executed in a subprocess will not write to the same trace output file (unless the name given to T_INIT is the same).
If any trace output is to be written but no output file has been opened by calling T_INIT, a default output file tt.out is opened automatically (see T_INIT).
The following (cpp) macros are used to generate trace output. These macros are substituted by no code, if the C compiler option -DNO_TT is given. Otherwise they have the following meaning:
The deletion of the trace output file in T_EXIT might be unexpected at first. But consider the following program fragment:
int main (int argc, char *argv[]) { T_INIT ("<prog>.out"); TTN (0, if (getenv ("SOSTRCLEVEL") == NULL) T_REDEF ("ih#200-")); T_EXIT(); exit (0); }
If the environment variable SOSTRCLEVEL is not set (note, that trace switch 0 will be activated in this case), the program will choose a default setting and generate a temporary trace output file. This file will be automatically removed in T_EXIT. In case of a fatal program error prior to calling T_EXIT, the output file will still exist and can be used in the error analysis.
The following macros output a value of the given type with the given representation:
Additionally, the macro
TXT (s)
can be used to write the string s directly into the trace output file.
For a module <m>, there are usually the four trace switches <m>_H, <m>_M, <m>_L, and <m>_VL, standing for high level, medium, low, and very low. Higher levels perform a trace on a more general level; <m>_H will usually generate a trace of the entry/exit of the more important module functions, a lower trace level will add entry/exit of auxiliary functions and a more detailed trace of functions whose entry/exit will appear in the higher trace level. The highest trace level used for a function should include function entry/exit.
The trace switches of a module are defined in a file trc_<m>.h in the module directory of trc, in order to have all trace switches together, thus avoiding duplicate trace switch numbers. Usually, 10 switches are reserved for a module starting with a multiple of 10. Of these, n (<m>_H) up to n + 3 (<m>_VL) are defined for all modules. Note, that traces on a high level can conveniently be activated using the t format option for the tracelevel string (see above).
As far as SOS is concerned, SOS application developers can safely use trace switches 200-499. However, possible conflicts with extensions to the SOS class library should still be taken into account. Currently, trace switch ranges are assigned to the SOS modules as follows:
All (relevant) function bodies are enclosed in test output; note that inner return statements must be preceded by a T_LEAVE.
int fun (char *s) { T_PROC ("fun") TT (mdl_H, T_ENTER; TS (s)); int i; ... if (...) { ... TT (mdl_H, T_LEAVE; TI (i)); return i; } ... TT (mdl_H, T_LEAVE; TI (i)); return i; }
D. Theobald